<template>
	<view>
		<ftabs :tablist='tabArr' @select='tabChange'></ftabs>
		<!-- 搜索框 -->
		<view class="search-box">
			<uni-search-bar @confirm="search" v-model="searchValue" @clear="clear" placeholder="请输入药品名称">
			</uni-search-bar>
		</view>

		<view class="info-list">

			<view class="table">
				<view class="tr">
					<text class="th ft16">名称</text>
					<text class="th ft16">单位</text>
					<text class="th ft16">单价(元)</text>
					<text class="th ft16">生产厂家</text>
				</view>

				<view class="tr bottom_dashed" v-for="(item,index) in tableData" :key="index"
					style='border-bottom: none'>
					<view class="td ft14">{{ item.title }}</view>
					<view class="td ft14">盒</view>
					<view class="td ft14 cl-red">￥34.63</view>
					<view class="td ft14">{{ item.companyName }}</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	import ftabs from '@/components/f-tabs'
	// import {
	// 	getMedical
	// } from '@/utils/api.js'

	export default {
		data() {
			return {
				searchValue: '',
				//初始化数据
				tabArr: Array.from(Array(15), (v, k) => {
					let item = {};
					item.id = k
					item.title = "分类 " + k
					return item
				}),
				tableData: Array.from(Array(15), (v, k) => {
					let item = {};
					item.id = k
					item.title = "复方鳖甲软肝片 " + k
					item.companyName = '内蒙古福瑞医疗'
					return item
				}),
				pageNum: 1,
				pageSize: 10,
				lastPage: false,
				loading: false,
			}
		},
		components: {
			ftabs
		},
		onReachBottom(e) {
			if (!this.lastPage && !this.loading) {
				this.pageNum++;
				this.getMedicalList()
			} else {
				uni.showToast({
					icon: 'none',
					position: 'bottom',
					title: '没有更多啦'
				});
			}
		},
		mounted() {
			this.getMedicalList()
		},
		methods: {

			async getMedicalList() {
				let reqBody = {
					service: "smarthos.drugs.price.announcement.project.list",
					itemName: '',
					projectType: ''
				}
				//let res = await getMedical();
				// this.tabArr=res.projectList
				// this.tableData=this.tableData.concat(res.dataList)
				//console.log(res)
			},
			tabChange(item) {
				console.log("fsdadsa", item)
				this.pageNum = 1
				this.tableData = []
				this.getMedicalList()
			},
			search(res) {
				uni.showToast({
					title: '搜索：' + res.value,
					icon: 'none'
				})
			},
		},
	}
</script>

<style scoped lang="scss">
	.table {
		width: 100%;
		border-radius: 8rpx;
		display: table;
		border-collapse: collapse;

		.th,
		.td {
			border: 1px solid #f2f2f2;
			padding: 8px;
			text-align: center;
			padding: 20rpx 0;
			display: table-cell;
		}

		.tr {
			display: table-row;
		}
	}
</style>